<?php
/**
 * Created by Veyron
 * User: Vy
 * motto:现在的拼搏 为了更好的明天
 * Class: User
 * day:  2020/1/20
 * Time: 16:11
 */

namespace app\api\validate;


use app\controller\Data;
use think\Validate;

class User extends Validate
{
    protected $rule = [
        'username'      => 'require',
        'phone_number'  => 'require|mobile',
        'code'          => 'require|number|min:4',
        'type'          => ['require','in'=>'1,2'],
        'sex'           => ['require','in'=>'0,1,2'],
    ];
    protected $message = [
        'username'               => '用户名不能为空',
        'phone_number.require'   => '手机号不能为空',
        'phone_number.mobile'    => '手机号不合法',
        'code.require'           => '验证码不能为空',
        'code.number'            => '验证码必须是数字',
        'code.min'               => '验证码长度不能少于4',
        'type.require'           => '类型不能为空',
        'type.in'                => '类型值错误',
        'sex.require'            => '性别不能为空',
        'sex.in'                 => '性别类型错误',
    ];
    protected $scene = [
        'send_code' => ['phone_number'], //场景，send_code 场景只验证 phone_number
        'login'     => ['phone_number','code','type'],
        'update'    => ['username','sex']
    ];

}
